<?php

namespace Modules\My;

/**
 * Description of Index
 *
 * @author Admin
 */
class Index extends \Core\Controller
{
	
	public function indexAction()
	{
		$this->_layout->meta()->title(_('Случайные карточки'));
		
		$this->rowset = \App::model('Vocabulary')->getRandomCart(9);
		
		$this->render();
		$this->render('left', 'right');
	}
	
	public function loginAction()
	{
		
		if($this->_isPost())
		{
			if(\App::model('User')->auth($this->_getParam('login'), $this->_getParam('password')))
			{
//				$redirect = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '';
//				
//				if(!$redirect)
					$redirect = $this->_layout->url('home');
				
				return $this->_redirect($redirect);
			}
		}
		
		if(!$this->_isXmlHttpRequest())
			$this->render();
	}
	
	public function logoutAction()
	{
		\App::model('User')->logout();
		
		return $this->_redirect($this->_layout->url('home'));
	}
	
}
